package pers.wensheng.patterns.behavioral_pattern.state_pattern.after;

import lombok.Getter;
import pers.wensheng.patterns.behavioral_pattern.state_pattern.after.entity.*;

/**
 * 环境角色类
 */
public class Context {
    /**
     * 定义对应状态对象的常量
     */
    public final static OpeningState OPENING_STATE = new OpeningState();
    public final static ClosingState CLOSING_STATE = new ClosingState();
    public final static RunningState RUNNING_STATE = new RunningState();
    public final static StoppingState STOPPING_STATE = new StoppingState();

    /**
     * 定义一个当前状态变量
     */
    @Getter
    public LiftState liftState;

    /**
     * 电梯操作方法
     */
    public void open(){
        this.liftState.open();
    }
    public void close(){
        this.liftState.close();
    }
    public void run(){
        this.liftState.run();
    }
    public void stop(){
        this.liftState.stop();
    }

    public void setLiftState(LiftState liftState) {
        this.liftState = liftState;
        //设置当前状态对象中的Context对象
        this.liftState.setContext(this);
    }
}
